<?php
include '../common/autoload.php';
if(!isset($_SESSION['memberID'])){
    echo "<script>window.location.href='/';</script>";
    exit;

}

$permit_arr = array(0,2,9);
$dtype = $_SESSION['dtype'];
if(!in_array($dtype, $permit_arr)) {
    exit('不合法的身份！');
}
$apply_did = $_SESSION['memberID'];
if($dtype==2) {
    $mem = new \pft\Member\MemberAccount($GLOBALS['le']);
    $account = $mem->getAccountById($apply_did);
}

$sql = "SELECT title,salerid,terminal,id,p_type FROM uu_land WHERE";
if(isset($_GET['sid'])) {
    $sql .= " id = " . intval($_GET['sid']);
}
elseif(isset($account)) {
    $sql .= " salerid={$account} AND status=1 ORDER BY p_type ASC";
}
else {
    $sql .= " apply_did={$apply_did} AND status=1 ORDER BY p_type ASC";
}
$GLOBALS['le']->query($sql);
$prods = array();
$prod_list = '';
$prod_detail = '';
while($r = $GLOBALS['le']->fetch_assoc()) {
    $prodList[] = $r;
}

if(count($prodList)) {
    $salerid = $prodList[0]['salerid'];
    foreach($prodList as $list) {
        $opts .= "<option value='{$list['salerid']}'>{$list['title']}</option>";
    }
}
else {
    $opts .= "<option value=''>没有相应产品</option>";
}
?>
<!doctype html>
<html lang="en">
<head>
    <title>验票系统</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="//y.12301.cc/css/gumby.css">
    <link rel="stylesheet" href="//y.12301.cc/css/public.css">
</head>
<body>
<div class="header">
    <h1 class="title">验票系统<a class="exit" href="clear.php">退出</a></h1>
</div>
<div class="container">
    <input type="hidden" name="uucode" value="<?=$lcode?>"/>
    <input type="hidden" name="ptype" value="<?=$prod_type?>"/>
    <div class="row">
        <div class="twelve columns">
            <fieldset>
                <ul class="mt1">
                    <li class="field">
                        <label for="salerList">产品名称：</label>
                        <div class="picker">
                            <select name="salerList" id="salerList">
                                <?=$opts?>
                            </select>
                        </div>
                    </li>
                    <li class="field">
                        <label for="certnum">凭证号：</label>
                        <input type="number" placeholder="请输凭证号" maxsize="6" name="certnum" id="certnum" class="wide text input"/>
                    </li>
                    <li class="field">
                        <input type="hidden" name="salerid" id="salerid" value="<?=$salerid?>"/>
                        <div class="medium pretty primary btn"><a href="javascript:" id="checkSubmitBtn">验证</a></div>
                        <a class="normal_lnk" href="javascript:" id="showOrder">查看今日订单</a>
                    </li>
                    <li class="field">
                        <div class="medium pretty secondary btn"><a href="javascript:" id="orderSearch">订单查询</a></div>

                    </li>
                </ul>
            </fieldset>
            <span id="msgShow"></span>
            <table>
                <tbody id="tbody" class="ok"></tbody>
            </table>
            <br/>
            <br/>
        </div>
    </div>
</div>
<div class="footer">
    <h1 class="title">&copy;票付通 版权所有</h1>
</div>
<script type="text/javascript" src="http://www.12301.cc/js/jquery-1.8.0.min.js"></script>
<script type="text/javascript" src="//y.12301.cc/js/mchk_terminal.min.js"></script>
</body>
</html>